#ifndef BUSINESSGROUP_H
#define BUSINESSGROUP_H

#include <QJsonObject>

#include <memory>
#include <map>
#include <protocol/protocolConverter.h>
#include <nlohmann/json.hpp>

class BusinessGroup
{
public:
    // 删除拷贝构造函数和拷贝赋值操作符
    BusinessGroup(BusinessGroup const&) = delete;
    BusinessGroup& operator=(BusinessGroup const&) = delete;
    // 提供一个全局唯一的接口
    static BusinessGroup& getInstance() {
        static BusinessGroup instance;
        return instance;
    }


    void createGroup(QJsonObject& in, QJsonObject & out);

    void updateGroupList(std::shared_ptr<Protocol> protocol);
    // GroupName GroupID Position
    nlohmann::json& getTargetGroup(const std::string& groupName);
    nlohmann::json &getTargetGroup(uint64_t groupID);

    void applyForRefreshGroupList(QJsonObject& in, QJsonObject& out);

    void applyForJoinAGroup(QJsonObject&in ,QJsonObject& out);

    void leaveGroup(QJsonObject& in, QJsonObject& out);

    void replyGroupApply(QJsonObject& in, QJsonObject& out);

    void updateGroupRequestList(std::shared_ptr<Protocol> protocol);

    void applyForRefreshGroupRequestList(QJsonObject& in, QJsonObject& out);

    void updateLocalMessage(QJsonObject& in, QJsonObject& out);

private:
    BusinessGroup();

    std::map<uint64_t, nlohmann::json> groupIDStore;
    std::map<std::string, nlohmann::json> groupNameStore;


};

#endif // BUSINESSGROUP_H
